<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="/static/pear/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form">
    <div class="mainBox  layui-card-body" style="padding: 0 0;">
        <div class="main-container">

            <div class="layui-form-item">
                <label class="layui-form-label">班级名称(CN)*</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入班级名称(CN)" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">班级名称(EN)*</label>
                <div class="layui-input-block">
                    <input type="text" name="e_name" lay-verify="required" autocomplete="off" placeholder="请输入班级名称(EN)" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">上课时间(CN)*</label>
                <div class="layui-input-block">
                    <input type="text" name="class_time" lay-verify="required" autocomplete="off" placeholder="请输入上课时间(CN)" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">上课时间(EN)*</label>
                <div class="layui-input-block">
                    <input type="text" name="e_class_time" lay-verify="required" autocomplete="off" placeholder="请输入上课时间(EN)" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">课程席位*</label>
                <div class="layui-input-block">
                    <select id="seats_type" name="seats_type" lay-filter="seats_type">
                        <option value="0">无限制</option>
                        <option value="1">指定人数</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item" id="seats" style="display:none;">
                <div class="layui-input-block">
                    <input style="width: 20%;display: inline-block;" type="text" value="0" name="seats" id="seats1" placeholder="请填写班级席位" class="layui-input"> 人
                </div>
            </div>
            <input type="hidden" name="courseid" value="{$courseid}">
            <input type="hidden" name="cate_id" value="{$cate_id}">
            <input type="hidden" name="flex_id" value="{$flex_id}">

            {:token_field()}
        </div>
    </div>


    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
{include file="_Fragment/javascript" /}
<script>
    layui.use(['form', 'jquery', 'element'], function() {
        let form = layui.form;

        let $ = layui.jquery;

        form.on('select(seats_type)', function(data){
            if (data.value == 1) {
                $('#seats').css('display','block');
            } else {
                $('#seats').css('display','none');
                $('#seats1').val(0);
            }
        });

        form.on('submit(user-save)', function(data) {
            let loading = layer.load();
            $.ajax({
                url: '/Flex/saveClasses',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function(result) {
                    layer.close(loading);
                    if (result.status == 0) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("user-table");
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>